package com.ajk.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ajk.server.dao.FriendPartientEventExtMapper;
import com.ajk.server.model.FriendPartientEventExt;
import com.ajk.server.model.query.FriendPartientEventExtQuery;
import com.ajk.server.service.FriendPartientEventExtService;

/**
 * 亲友健康数据扩展表  <br>
 * t_friend_partient_event_ext <br>
 * v1.0 2016-05-12
 */
 @Service
 public class FriendPartientEventExtServiceImpl implements FriendPartientEventExtService {
	
	private static final Logger logger = LoggerFactory.getLogger(FriendPartientEventExtServiceImpl.class);
	
	@Autowired
	private FriendPartientEventExtMapper friendPartientEventExtMapper;
	
	/**
 	*根据ID删除 亲友健康数据扩展表
 	*/
 	@Override
 	public Integer deleteFriendPartientEventExtById(Integer id){
 		return friendPartientEventExtMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 亲友健康数据扩展表
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertFriendPartientEventExt(List<? extends FriendPartientEventExt> friendPartientEventExts){
		Integer count = friendPartientEventExtMapper.batchInsert(friendPartientEventExts);
		return count;
 	}
 	/**
 	*新增 亲友健康数据扩展表
 	*/
 	@Override
 	@Transactional
 	public Integer insertFriendPartientEventExt(FriendPartientEventExt domain){
		Integer id = friendPartientEventExtMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 亲友健康数据扩展表
 	*/
 	@Override
 	@Transactional
 	public Integer updateFriendPartientEventExt(FriendPartientEventExt domain){
		Integer count = friendPartientEventExtMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 亲友健康数据扩展表
 	*/
 	public FriendPartientEventExt findFriendPartientEventExtById(Integer id){
 		FriendPartientEventExt result = friendPartientEventExtMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 亲友健康数据扩展表
 	*/
	public List<FriendPartientEventExt> findFriendPartientEventExtByQuery(FriendPartientEventExtQuery query){
		query.dealWith();
		List<FriendPartientEventExt> result = friendPartientEventExtMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (FriendPartientEventExt friendPartientEventExt : result) {
				friendPartientEventExt.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countFriendPartientEventExtByQuery(FriendPartientEventExtQuery query){
 		query.dealWith();
 		Integer result = friendPartientEventExtMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<FriendPartientEventExt> findFriendPartientEventExtByIds(List<Integer> ids){
 		List<FriendPartientEventExt> result = friendPartientEventExtMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (FriendPartientEventExt friendPartientEventExt : result) {
				friendPartientEventExt.dealWith();
			}
		}
		return result;
 	}
 	
}	